<template>
	<uv-tags :text="text" :plain="plain" size="mini" :type="type"></uv-tags>
</template>

<script>
	// primary |success | info | warning | error
	import { findConstant } from '@/common/lib/constant.js'
	export default {
		props: {
			value: {
				type: [String,Number],
				default: ""
			},
			prop: {
				type:String,
				default: ""
			},
			plain: {
				type:Boolean,
				default: false
			}
		},
		data() {
			return {
				text: '',
				type:'primary'
			}
		},
		mounted(){
			this.initTag()
		},
		watch: {
			value(newValue, oldValue) {
				this.initTag()
			}
		},
		methods: {
			initTag() {
				let constant = findConstant(this.prop,this.value);
		
				if(constant){
					this.text = constant.label
					this.type = constant.type
				}
			}
		},
	}
</script>

<style>
</style>